<?php

class UloginController extends CController {

    public function actionLogin() {
        if (isset($_POST['token'])) {
            $ulogin = new UloginModel();
            $ulogin->setAttributes($_POST);
            $ulogin->getAuthData();
            if ($ulogin->validate() && $ulogin->login()) {
                $this->redirect(Yii::app()->user->returnUrl);
            } else {
                $this->redirect(array('user/default/login', 'uloginErrors'=>serialize($ulogin->getErrors())));
            }
        } else {
            $this->redirect(Yii::app()->homeUrl, true);
        }
    }
}